package com.hb.core.pojo.project.section.dto;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hb.core.pojo.Attachments;
import com.hb.core.pojo.enums.ProblemStatusEnum;
import com.hb.core.pojo.project.section.entity.Clarify;
import com.hb.core.pojo.project.section.entity.ClarifySection;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.fzzn.core.util.Enums;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * @author gaoyf
 * @date 2021-9-23 14:21
 * @description 澄清答疑VO
 */
@Getter
@Setter
public class ClarifyDTO extends Clarify {

    @ApiModelProperty(value = "投标人ID")
    private Long tenderId;

    @ApiModelProperty(value = "标段id")
    private Long sectionId;
    @ApiModelProperty(value = "标段名称")
    private String sectionName;

    @ApiModelProperty(value = "项目名称")
    private String projectName;

    @ApiModelProperty(value = "项目编号")
    private String projectCode;

    @ApiModelProperty(value = "标段列表")
    private List<ClarifySection> sectionList;

    @ApiModelProperty(value = "澄清问题回复人")
    private String replyName;

    @ApiModelProperty(value = "投标人名称")
    private String tenderName;

    @ApiModelProperty(value = "是否需要确认")
    private boolean confirm = false;

    @ApiModelProperty(value = "是否确认(1:是  2:否)")
    private Integer confirmFlag;

    @ApiModelProperty(value = "1 资格预审文件澄清 2 招标/采购文件澄清")
    private Integer fileType;

    @ApiModelProperty(value = "1 待发出 2 已发出")
    private String statusName;

    @ApiModelProperty(value = "未确认/已确认/总数")
    private String statusCount;


    @ApiModelProperty(value = "回执时间")
    @JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime receiptTime;


    @ApiModelProperty(value = "签章回执文件")
    private Attachments receiptFileSignature;

    @ApiModelProperty(value = "企业名称")
    private String orgName;



    /**
     * ClarifyList 转换 ClarifyDto
     * @param clarifyList
     * @return
     */
    public static List<ClarifyDTO> changeClarifyDto(List<Clarify> clarifyList){
        List<ClarifyDTO> clarifyDtoList = CollUtil.list(false);
        if (CollUtil.isEmpty(clarifyList)){
            return clarifyDtoList;
        }
        for (Clarify clarify : clarifyList) {
            ClarifyDTO clarifyDto  = clarify.to(ClarifyDTO.class);

            clarifyDto.setStatusName(Enums.nameOf(ProblemStatusEnum.class,clarifyDto.getStatus()));
            clarifyDtoList.add(clarifyDto);
        }
        return clarifyDtoList;
    }
}
